﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Spanner
{
    // Library models (i.e., top-level classes) must be subclasses of this.
    public class LibraryModel: Model
    {
        internal LibraryModel() { } // Keep C# happy with a nullary constructor.

        public LibraryModel(string name, Act initAct, params Model[] modelDependencies)
        {
            Name = name;
            Html = null;
            ModelDependencies = modelDependencies;
            InitParam = null;
            InitAct = initAct;
            IsLibraryModel = true;
            IsTemplateModel = false;
            NonSpannerImplementationJS = null;
            NonSpannerJSUrl = null;
        }
    }

    // A global non-spanner library with code provided.  The Spanner API can be provided via
    // field declared with type Expr<>.
    public class NonSpannerLibraryModel: LibraryModel
    {
        internal NonSpannerLibraryModel() { }

        public NonSpannerLibraryModel(string name, string verbatimJS, params Model[] modelDependencies)
        {
            Name = name;
            Html = null;
            ModelDependencies = modelDependencies;
            InitParam = null;
            InitAct = null;
            IsLibraryModel = true;
            IsTemplateModel = false;
            NonSpannerImplementationJS = verbatimJS;
            NonSpannerJSUrl = null;
        }
    }

    // A global non-spanner library with external URL provided.  The Spanner API can be provided via
    // field declared with type Expr<>.
    public class ExternalNonSpannerLibraryModel: LibraryModel
    {
        internal ExternalNonSpannerLibraryModel() { }

        public ExternalNonSpannerLibraryModel(string name, string jsUrl, params Model[] modelDependencies)
        {
            Name = name;
            Html = null;
            ModelDependencies = modelDependencies;
            InitParam = null;
            InitAct = null;
            IsLibraryModel = true;
            IsTemplateModel = false;
            NonSpannerImplementationJS = null;
            NonSpannerJSUrl = jsUrl;
        }
    }
}
